{% extends "base_generic.html" %}

{% load widget_tweaks %}

{% block content %}
  <div class="card" style="max-width: 600px; margin: 50px auto;">
    <h1>{% if object %}编辑{% else %}添加{% endif %}作者</h1>
    <form action="" method="post">
      {% csrf_token %}
      {% for field in form %}
        <div class="form-group">
          <label for="{{ field.id_for_label }}">{{ field.label_tag }}</label>
          {{ field|add_class:"form-control" }}
          {% if field.help_text %}
            <small class="form-text text-muted">{{ field.help_text }}</small>
          {% endif %}
          {% if field.errors %}
            {% for error in field.errors %}
              <p class="text-danger">{{ error }}</p>
            {% endfor %}
          {% endif %}
        </div>
      {% endfor %}
      <button type="submit" class="btn btn-primary">提交</button>
      <a href="{% url 'authors' %}" class="btn btn-secondary" style="margin-left: 10px;">取消</a>
    </form>
  </div>
{% endblock %}
